package top.huntwolf.admin.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import top.huntwolf.admin.exception.ServiceException;

@AllArgsConstructor
public enum BookConditionEnum implements EnumValue{


    MEDIUM((short)0,"中等"),

    NEW((short)1,"全新"),

    GOOD((short)2,"良好"),

    NOTE((short)3,"学霸");



    private final short value;
    private final String desc;

    
    public String desc() {
        return desc;
    }

    public short getValue() {
        return value;
    }

    @Override
    public Object toValue() {
        return value;
    }

    public static BookConditionEnum getConditionByDesc(String desc){
        switch (desc){
            case "中等":
            case "MEDIUM":
                return MEDIUM;
            case "全新":
            case "NEW":
                return NEW;
            case "良好":
            case "GOOD":
                return GOOD;
            case "学霸":
            case "NOTE":
                return NOTE;
        }
        throw new ServiceException(CodeMsg.WRONG_BOOK_CONDITION.fillArgs("书本品相错误"));
    }
}
